﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Sharp.Platform.Mvc;
using Sharp.Platform.Mvc.Extensions;
using Sharp.Platform.Mvc.Route;

namespace Sharp.WebBooter
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            var jsonValue = ValueProviderFactories.Factories.FirstOrDefault(x=>x is JsonValueProviderFactory);
            ValueProviderFactories.Factories.Remove(jsonValue);

            ValueProviderFactories.Factories.Add(new JsonDotNetValueProviderFactory());

            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapSaasRoute(
               name: "Login",
               url: "Login",
               defaults: new { controller = "Account", action = "Login", id = UrlParameter.Optional }
               );

            routes.MapSaasRoute(
                          name: "ResetPassword",
                          url: "ResetPassword/{token}",
                          defaults: new { controller = "Account", action = "ResetPassword" }
                          );

            routes.MapSaasRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
                namespaces: new string[] { "Sharp.WebBooter.Controllers" }
            );
        }
    }
}
